<!--问题反馈-->
<template>
  <div>
    <el-form ref="form" label-width="120px" :rules="rules" :model="Feedback">
      <el-form-item label="品牌/型号：" prop="Name">
        <el-input v-model="Feedback.Name" maxlength="100" style="width:70%;" size="medium" disabled />
      </el-form-item>
      <el-form-item label="反馈类型：" prop="FeedbackType">
        <el-select v-model="Feedback.FeedbackType" placeholder="反馈类型" disabled style="width:70%;" size="medium">
          <el-option v-for="dict in FeedbackType" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="反馈信息：" prop="FeedbackText">
        <el-input v-model="Feedback.FeedbackText" style="width:70%;" size="medium" type="textarea" autosize maxlength="300" show-word-limit/>
      </el-form-item>

    </el-form>
    <div slot="footer" style="text-align:right">
      <el-button size="medium" @click="handleClose">取 消</el-button>
      <el-button size="medium" type="primary" @click="handSave">反 馈</el-button>
    </div>
  </div>
</template>

<script>
import { save } from './../api/brand'; //引入api 的接口
import { getEnumerate } from './../api/category'; 
let defaultmodel = {
  ID: undefined,
  Name: undefined,
  FeedbackType: undefined,
  FeedbackText: undefined,
  FromID: undefined
};
export default {
  name: 'Feedback',
  data() {
    //这里存放数据
    return {
      loading: false,
      ID: null,
      Feedback: Object.assign({}, defaultmodel),
      FeedbackType: {}, // 反馈类型
      rules: {
        Name: [{ required: true, message: '型号/品牌获取失败', trigger: 'blur' }],
        FeedbackType: [{ required: true, message: '反馈类型获取失败', trigger: 'blur' }],
        FeedbackText: [{ required: true, message: '请输入反馈内容', trigger: 'blur' }]
      }
    };
  },
  methods: {
    loadfrom(model) {
      this.Feedback = model;
      getEnumerate(['FeedbackType']).then(res => {
        this.FeedbackType = res.data.FeedbackType;
      });
    },
    handSave() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.loading = true;
          save(this.Feedback).then(res => {
            if (res.success) {
              this.msgSuccess('信息已反馈！');
              this.resetForm('form');
              this.handleClose();
            } else {
              this.msgError(res.data);
            }
            this.loading = false;
          });
        }
      });
    },
    // 关闭按钮
    handleClose() {
      this.resetForm('form');
      this.$emit('close');
    }
  }
};
</script>
